<template>
    <div class="change">
        <van-nav-bar title="修改密码" left-arrow @click-left="$router.back()"></van-nav-bar>

        <!-- 表单验证 -->
    <van-form @submit="onSubmit" ref="regForm">
      <van-field
        v-model="oldPassword"
        type="oldPassword"
        name="oldPassword"
        label="旧密码"
        placeholder="旧密码"
        :rules="[
          { required: true, message: '请填写密码' },
          { validator: (e) => /^\w{6,12}$/.test(e), message: '密码格式错误' },
        ]"
      />
      <van-field
        v-model="newPassword"
        type="newPassword"
        name="newPassword"
        label="新密码"
        placeholder="新密码"
        :rules="[
          { required: true, message: '请填写密码' },
          { validator: (e) => /^\w{6,12}$/.test(e), message: '密码格式错误' },
        ]"
      />
      <div style="margin: 16px">
        <van-button round block type="info" native-type="submit" @click="onSubmit" color="#05be6b"
          >提交</van-button
        >
      </div>
    </van-form>
    </div>
</template>

<script>

import { UpdatePwd } from "@/api/user.js";
export default {
  data() {
    return {
      newPassword: "",
      oldPassword: "",
    };
  },
  created() {
   
  },
  mounted() {},
  methods: {
    // 修改密码请求
    onSubmit(values) {
       let uid=this.$store.state.uid
       console.log(uid);
      console.log("submit", values);
      let {oldPassword,newPassword}=values
      UpdatePwd({
        oldPassword,
        newPassword,
        uid
      }).then((res) => {
        console.log(res);
      });
    },
  },
};
</script>

<style lang="less">

</style>